package com.itheima.test7;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;

/**
 * @Author:gy
 * @Date: 2025/09/03 16:49
 * @Description:
 */
public class ClientDemo {
    public static void main(String[] args) throws Exception {
        //找码头  客户端的套接字对象
        DatagramSocket ds = new DatagramSocket();
        //打包礼物
        String s = "一条华子,两瓶台子";
        byte[] bytes = s.getBytes();
        InetAddress ip = InetAddress.getByName("127.0.0.1");
        DatagramPacket dp = new DatagramPacket(bytes,bytes.length,ip,10000);
        //码头最后发礼物
        ds.send(dp);
        //付钱走人 关闭发送端
        ds.close();
    }
}
